﻿using BackData;
using Domain;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Rabbit.API.Application.Command.Breed;

namespace Rabbit.API.Controllers
{
    /// <summary>
    /// 养殖管理控制器  编辑养殖信息正在做
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BreedController : ControllerBase
    {
        IMediator mediator;

        public BreedController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取商品养殖信息
        /// </summary>
        /// <param name="request">参数</param>
        /// <param name="cancellationToken">取消</param>
        /// <returns>商品养殖数据</returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<APIResult<BreedModel>> BreedGet([FromQuery]BreedGetCommand request)
        {
            try
            {
                return mediator.Send(request);   
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 修改兔子养殖信息
        /// </summary>
        /// <param name="request">参数</param>
        /// <param name="cancellationToken">取消</param>
        /// <returns>影响行数</returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public async Task<APIResult<int>> BreedUpdate(BreedUpdateCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }


    }
}
